<template>
  <div>
    <Button type="primary" @click="$router.push('/admin/addteam')" style="margin-bottom:20px;">添加团队成员</Button>
    <Table :columns="columns" :data="teamData"></Table>
    <Modal v-model="feedModal" width="550">
      <p slot="header">
        <span>查看反馈</span>
      </p>
      <div style="text-align:left;font-size: 14px;">
        <p><strong>姓名：</strong><span>{{modalData.name}}</span></p>
        <Divider />
        <p><strong>英文名：</strong><span>{{modalData.enname}}</span></p>
        <Divider />
        <p><strong>职位：</strong><span>{{modalData.title}}</span></p>
        <Divider />
        <p><strong>个人介绍：</strong><span>{{modalData.jieshao}}</span></p>
        <Divider />
        <p><strong>照片：</strong><img :src="modalData.photo" alt=""></p>
      </div>
      <div slot="footer">
        <Button type="success" @click="feedModal=false">确定</Button>
      </div>
    </Modal>
  </div>
</template>

<script>
export default {
  layout: "admin",
  data() {
    return {
      columns: [
        {
          title: "#",
          type: "index"
        },
        {
          title: "姓名",
          key: "name"
        },
        {
          title: "英文名",
          key: "enname"
        },
        {
          title: "职称",
          key: "title"
        },
        {
          title: "团队",
          render: (h, param) => {
            const td = param.row.type == 1 ? '顾问' : '专家'
            const color = param.row.type == 1 ? 'primary' : 'success'
            return h('Tag', {
              props: {
                color: color
              }
            }, td)
          }
        },
        {
          title: "操作",
          render: (h, param) => {
            return h("Button", {
              props: {
                type: "primary"
              },
              on: {
                click: () => {
                  this.modalData = param.row
                  this.feedModal = true
                }
              }
            }, '查看详情');
          }
        }
      ],
      teamData: [],
      modalData: {
        name: '',
        address: '',
        contact: '',
        yixiang: '',
        problem: '',
        datetime: '',
        ip: ''
      },
      feedModal: false
    };
  },
  methods: {
    getList(url, _this) {
      _this.$axios.get(url).then(res => {
        if (res.data.code == 200) {
          _this.teamData = res.data.detail
        } else {
          _this.$Message.error('获取列表失败，请稍后重试！')
        }
      }).catch(err => {
        _this.$Message.error('网络错误，请稍后重试！')
      })
    }
  },
  mounted() {
    const url = '/adminapi/getTeamList'
    this.$options.methods.getList(url, this)
  }
};
</script>
